package quchong;

import com.etc.JopSubmit;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class Submit {
    public static void main(String[] args) {
        Configuration configuration = new Configuration();
        try{
            //新建一个job工作
            Job job = new Job(configuration);
            //设置运行类
            job.setJarByClass(JopSubmit.class);
            //设置执行的mapper类
            job.setMapperClass(Map.class);
            //设置执行的reduce类
            job.setReducerClass(Reduce.class);
            //设置输出的key类
            job.setMapOutputKeyClass(Text.class);
            //设置输出的value类
            job.setMapOutputValueClass(Text.class);
            //设置value的任务个数。默认为1.一般reduce越多越高效
            job.setNumReduceTasks(1);
            //设置输入的数据路径
            FileInputFormat.setInputPaths(job,new Path("f:/file1.txt"));
            //设置输出的数据路径
            FileOutputFormat.setOutputPath(job,new Path("f:/file.txt"));
            //执行完毕退出
            System.exit(job.waitForCompletion(true) ? 0:1);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
